bash -x ./post_to_commandlinefu.sh

runs a bash script in debugging mode

Sample Output
bash -x ./post_to_commandlinefu.sh bash -x ./post_to_commandlinefu.sh 
+ COMMAND='bash -x ./post_to_commandlinefu.sh'
+ echo 'command is bash -x ./post_to_commandlinefu.sh'
command is bash -x ./post_to_commandlinefu.sh
+ '[' 'bash -x ./post_to_commandlinefu.sh' = '' ']'
+ SESSIONFILE=./.c
+ LOGINURL=http://www.commandlinefu.com/users/signin
+ EDITURL=http://www.commandlinefu.com/commands/edit
++ dirname ./.c
++ basename ./.c
+ find . -name .c -mtime +1 -exec rm '{}' ';'
+ '[' '!' -f ./.c ']'
+ echo -n 'Enter commandlinefu username: '
Enter commandlinefu username: + read USERNAME

+ echo -n 'Enter commandlinefu password: '
Enter commandlinefu password: + read -s PASSWORD
+ echo

+ wget -O - --save-cookies ./.c --keep-session-cookies --post-data 'username=&password=&remember=on&submit=Let me in!' http://www.commandlinefu.com/users/signin
+ echo -n 'Enter summary (required): '
Enter summary (required): + read SUMMARY
runs a bash script in debugging mode
++ echo runs a bash script in debugging mode
++ cut -c1-154
+ SUMMARY='runs a bash script in debugging mode'
++ echo bash -x ./post_to_commandlinefu.sh
++ cut -c1-254
+ COMMAND='bash -x ./post_to_commandlinefu.sh'
+ echo 'post-data is command=bash -x ./post_to_commandlinefu.sh&summary=runs a bash script in debugging mode&submit=Save'
post-data is command=bash -x ./post_to_commandlinefu.sh&summary=runs a bash script in debugging mode&submit=Save
+ wget -O - --load-cookies ./.c --post-data 'command=bash -x ./post_to_commandlinefu.sh&summary=runs a bash script in debugging mode&submit=Save&' http://www.commandlinefu.com/commands/edit
+ rm -f browse edit
+ rm -f '*17274*'

25
By: nottings
2009-02-25 19:10:21

3 Alternatives + Submit Alt

What Others Think

just running set -x first accomplishes the same thing or, add set -x within your script at the point you want to turn debugging on
nottings · 481 weeks and 6 days ago
Also debugging can be turned on at the top of the script when declaring the shell type: #!/bin/bash -x
hellspawn · 481 weeks and 5 days ago
thanks hellspawn! didn't know that, but it makes sense.
nottings · 481 weeks and 4 days ago
Thanks chaps. Made a lot of people at my place very happy.
mccalni · 479 weeks and 4 days ago
How is it debugging? Does is it just more verbose? It would be cool if there was a "safe-mode" where it blocks all writes to devices.
matthewbauer · 450 weeks and 5 days ago
see http://www.davidpashley.com/articles/writing-robust-shell-scripts.html for tips for safer, more robust coding
nottings · 391 weeks and 5 days ago
Inside script "set -x" turns on debugging. "set +x" turns off debugging. Bash example: set -x; ls; ps; set +x
0xFF · 264 weeks and 2 days ago

What do you think?

Any thoughts on this command? Does it work on your machine? Can you do the same thing with only 14 characters?

You must be signed in to comment.

What's this?

commandlinefu.com is the place to record those command-line gems that you return to again and again. That way others can gain from your CLI wisdom and you from theirs too. All commands can be commented on, discussed and voted up or down.

Share Your Commands



Stay in the loop…

Follow the Tweets.

Every new command is wrapped in a tweet and posted to Twitter. Following the stream is a great way of staying abreast of the latest commands. For the more discerning, there are Twitter accounts for commands that get a minimum of 3 and 10 votes - that way only the great commands get tweeted.

» http://twitter.com/commandlinefu
» http://twitter.com/commandlinefu3
» http://twitter.com/commandlinefu10

Subscribe to the feeds.

Use your favourite RSS aggregator to stay in touch with the latest commands. There are feeds mirroring the 3 Twitter streams as well as for virtually every other subset (users, tags, functions,…):

Subscribe to the feed for: