Tech or Treat! Write an article about your scariest tech disaster to win gadgets!Learn more

x
?
Solved

Batch file question

Posted on 2013-01-15
6
Medium Priority
?
600 Views
Last Modified: 2013-01-29
so I have the following command that works at the command prompt
 
sqlite3 mydb.db < udpate.txt

or

sqlite3 mydb.db < reset.txt

because I have to do this often for testing I want to batch these commands.

When I do the command line interpreter reads the < as a less than sign and puts a 0 infront.  So my actual script file appears now as:
sqlite3 mydb.db 0< udpate.txt

Anyone know how to have this interpreted correctly?

thanks
0
Comment
Question by:bschiel
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
6 Comments
 
LVL 12

Expert Comment

by:duttcom
ID: 38781042
You could try escaping the less-than sign with three carets -

sqlite3 mydb.db ^^^< udpate.txt
0
 
LVL 14

Expert Comment

by:ThomasMcA2
ID: 38781132
The redirect arrow (<) is a common DOS method. I've been writing DOS batch files for over 20 years, and I've never seen that behavior. Are you sure it's not your text editor adding that extra character? Can you remove the extra character in your text editor? Try these ideas:

From a DOS prompt, type the contents of your batch file to the screen:
type your_batch.bat

Open in new window

Is the character displayed on the screen?

If you have echo off or @echo off at the top of your script, comment it out with REM, then try again. The script will echo each command on the screen. Is the extra character still there?

If you still can't get rid of the extra character, attach your batch script to your reply.
0
 

Author Comment

by:bschiel
ID: 38781659
I rewrote the batch file using copy con and get the same results.  

I will try the ^^^ route in the morning and report back.
0
Prepare for your VMware VCP6-DCV exam.

Josh Coen and Jason Langer have prepared the latest edition of VCP study guide. Both authors have been working in the IT field for more than a decade, and both hold VMware certifications. This 163-page guide covers all 10 of the exam blueprint sections.

 
LVL 57

Accepted Solution

by:
Bill Prew earned 400 total points
ID: 38782311
The 0< is just how the command interpretter expands the < redirection symbol. There are a number of special handles that can be used, as referenced here:

http://www.microsoft.com/resources/documentation/windows/xp/all/proddocs/en-us/redirection.mspx?mfr=true

In your batch file though, you can put the same thing you are typing at a command prompt that is working, as in below, there should be no need to do anything more than that.

@echo off
sqlite3 mydb.db < reset.txt

Open in new window

Of course this assumes that reset.txt is in the current directory when the BAT file runs, so if that isn't the case then you may want to add a PUSHD or CD to the BAT script, or fully qualify the file name(s) it uses.

~bp
0
 
LVL 14

Expert Comment

by:ThomasMcA2
ID: 38783726
Nice reference, Bill, I bookmarked that.

My point is that although 0 represents keyboard input, there is no automated process that replaces < with 0<, thereby breaking redirection.

After rereading the OP, it looks like the 0 is part of the script:
So my actual script file appears now as:
sqlite3 mydb.db 0< udpate.txt

If so, just delete the 0, save the script, then rerun it.

If that doesn't fix it, please attach screenshots of the problem. Include the following screenshots:
1) The script itself, opened in Notepad
2) The "type" command that displays the script in the console
3) The command prompt where you run the script so we can see the results and/or errors

Tom
0
 

Author Comment

by:bschiel
ID: 38832186
So it turns out that the sqlite program solves this issue for me.  Just found out there is a switch on the exe that solves this problem.  sqlite3 -echo will use the stdout to display the commands feed to it.  So now I see exactly what I want to see and can verify what I am feeding my DB when i combine it with the @echo off.

Thanks all.
0

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article provides a convenient collection of links to Microsoft provided Security Patches for operating systems that have reached their End of Life support cycle. Included operating systems covered by this article are Windows XP,  Windows Server…
Lotus Notes has been used since a very long time as an e-mail client and is very popular because of it's unmatched security. In this article we are going to learn about  RRV Bucket corruption and understand various methods to Fix "RRV Bucket Corrupt…
Finding and deleting duplicate (picture) files can be a time consuming task. My wife and I, our three kids and their families all share one dilemma: Managing our pictures. Between desktops, laptops, phones, tablets, and cameras; over the last decade…
If you’ve ever visited a web page and noticed a cool font that you really liked the look of, but couldn’t figure out which font it was so that you could use it for your own work, then this video is for you! In this Micro Tutorial, you'll learn yo…

649 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question