0

Whenever I execute a bash script with a tshark command via command prompt, it will not work, displaying "command not found".

I have added a path to the PATH environment variable and tshark works in command prompt itself, however should a tshark command be executed via a bash script that is when the issue arises.

For instance,

tshark -r <filename here> -e ip.src -e eth.src -e ip.dst -e eth.dst -e ip.ttl -T fields -E separator="," > new.csv

works as intended when inputted directly into command prompt, however does not work when in a .sh script that is executed via command prompt.

Rob Rorry
  • 51
  • 2
  • 5
  • Have you used the `export` keyword while editing the `PATH` variable? (https://stackoverflow.com/q/7411455/3052438) – Piotr Siupa Feb 09 '22 at 05:48
  • @NO_NAME I have not edited the PATH variable in the script - only in System Properties > Environment variables such that tshark is recognized outside the directory when a command is issued in command prompt. However, even when in the same directory, the script will not work. – Rob Rorry Feb 09 '22 at 06:13
  • Does the path to `tshark` appear when you're printing the `PATH` from inside the script? Also, make sure the script doesn't have Windows file endings. It can give weird result like this. – Piotr Siupa Feb 09 '22 at 06:23
  • Yes, the PATH variable has all the relevant paths - particularly to tshark - both when displayed in command prompt and when executing from the script. And the file extension is .sh if that is what you mean by file endings. – Rob Rorry Feb 09 '22 at 06:34
  • Sorry, I've meant line endings. – Piotr Siupa Feb 09 '22 at 07:28
  • Can you provide any other debug from your script? For example, by adding a `set -x` command to the top. Run `help set` for other `set` options. Also, is the path to `tshark` in root's `$PATH`? If not, does adding it to root's `$PATH` help? Maybe the script is being run with elevated privileges? – Christopher Maynard Feb 09 '22 at 17:44

0 Answers0