Hi all, I'm doing a program with among others, the following script, wich is called "call":
Which should do the following:
Accept some arguments, execute the arguments as a command, and if there is a " ", or a "/" in the arguments, change them to "_" and "\". And save the output of stdout in a file at /root/test in the format 'command_with_no_spaces_and_"\".20120515134527' (please note the slash has been changed for a backslash xD).
So I insert the following command in shell:
I guess that's because a file can't be written with a slash, which, even though I've tried changing it (the slash) in many ways, it seems impossible. I DO have the permissions to write in that directory, and I'm using /bin/sh.
Any thoughts?
Any help would be greatly appreciated.
Many thanks for your time
Code:
#!/bin/sh
DIR=/root/test
COMMAND=`echo $@ | tr -s "\/"," " "\\","_"`
$@ > $DIR/`echo "$COMMAND"`.`date +%Y%m%d%H%M%S`
Which should do the following:
Accept some arguments, execute the arguments as a command, and if there is a " ", or a "/" in the arguments, change them to "_" and "\". And save the output of stdout in a file at /root/test in the format 'command_with_no_spaces_and_"\".20120515134527' (please note the slash has been changed for a backslash xD).
So I insert the following command in shell:
# call nmap -sn 192.168.1.1/24
Code:
/root/bin/call: line 3: nmap_-sn_192.168.1.1/25.20120420102654: No such file or directory
I guess that's because a file can't be written with a slash, which, even though I've tried changing it (the slash) in many ways, it seems impossible. I DO have the permissions to write in that directory, and I'm using /bin/sh.
Any thoughts?
Any help would be greatly appreciated.
Many thanks for your time