473,395 Members | 1,462 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,395 software developers and data experts.

Batch file does not run as required from Python.

I have made a batch file (auto.bat) as follows:

cd C:\Program Files (x86)\Wireshark
tshark -i 3 -w "C:\Users\Vivek Ganti\pcap_file.pcap"
tshark -nr "C:\Users\Vivek Ganti\pcap_file.pcap" -T text > "C:\Users\Vivek Ganti\myoutput.txt"

This is basically to start Wireshark, sniff packets, save it on a pcap file, and then export it to a text file so i can later parse the file.

When i run "auto.bat" from the cmd prompt, it runs great- stores the pcap file and the exported text file.

But when i do os.system("auto.bat") or subprocess.call ("auto.bat"), it does not store the pcap file or the exported txt file. On the Python shell i get a return code of 0 (though the command window opens and captures packets- just doesnt save them in a file).

Please help.

Thank you very much,
Vivek
Jul 27 '10 #1
1 1958
Glenton
391 Expert 256MB
Return code of 0 means that it has successfully run the script.

I'm guessing that the issue is the directory that your running in. You can change the current working directory (cwd) in python before running the script.

I think that probably not doing so will just run auto.bat wherever you happen to be, so the auto.bat that you want to run is not being found. However, there is possibly a universal auto.bat that is being found and being run which is why it runs without error.

Try changing your file name to auto2.bat or something, and see if the python code throws an error. If it does then it's probably something like the above!
Aug 3 '10 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

3
by: DBA | last post by:
I have a windows batch file that executes a SQL Server bcp command. I would like to obtain a return code if the bcp command fails. However, I cannot seem to find the return code (if any) for bcp....
0
by: SkySea | last post by:
Hi! Any help on this would be appreciated... In an HTML document that lists instructions on installing some software, there's a point where a DOS batch file needs to be run in order to copy...
14
by: Mark C. | last post by:
I'm trying to call a batch file that I've built using the FileSystemObject and CreateObject("Wscript.Shell"), oShell.Run... in an asp script. Naturally, I can get the script to work from a command...
4
by: Bill | last post by:
I need help closing a CMD window when it is executed from Access. 1) The batch file is called from Access. 2) Access closes, 3) the batch runs a copy of the access database (creating a backup)...
1
by: Bucky Pollard | last post by:
I have a web service that needs to create a batch file and call it (since there are no APIs for the functionality I am looking for). I am using the Process and ProcessStartInfo objects. When I try...
2
by: DB | last post by:
Hi All, I have to execute dos command containing batch file using asp.net application. Code for batch file execution is working properly when I tried it with console application but same code...
3
by: emman_54 | last post by:
Hi every one, I am trying to run a batch file using my asp.net application. I am using the Process class to run the batch file. When I run my web application, In the task manager, i could see...
3
by: n o s p a m p l e a s e | last post by:
Suppose I have a batch file called mybatch.bat and I want to run it from a python script. How can I call this batch file in python script? Thanx/NSP
2
by: Fabian Braennstroem | last post by:
Hi, me again :-) I would like to parse a small batch file: file/read-case kepstop.cas file/read-data keps1500.dat solve/monitors/residual/plot no solve/monitors/residual/print yes
14
by: =?Utf-8?B?R2lkaQ==?= | last post by:
Hi, In my windows applicationm, i need to excute a batch file. this batch file throws some text and questions to the screen, i need to catch the standard Output, check if it's a question, in...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.